package com.synergy.stockflow.procure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.synergy.stockflow.sales.entity.CustomerResources;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.synergy.stockflow.procure.mapper.VendorMapper;
import com.synergy.stockflow.procure.entity.Vendor;
import com.synergy.stockflow.procure.service.VendorService;
@Service
public class VendorServiceImpl extends ServiceImpl<VendorMapper, Vendor> implements VendorService{


    @Override
    public Page<Vendor> getVendor(Page<Vendor> page, String vendorName, String vendorGrade, String vendorSettlementperiod, String vendorHeadofpurchasing, String vendorContactphone) {
        QueryWrapper<Vendor> query = new QueryWrapper<>();
        if(vendorName!=null&&vendorName.length()>0){
            query.lambda().like(Vendor::getVendorName,vendorName);
        }
        if(vendorGrade!=null
                &&!vendorGrade.equals("全部")
                &&vendorGrade.length()>0){
            query.lambda().like(Vendor::getVendorGrade,vendorGrade);
        }
        if(vendorSettlementperiod!=null
                &&!vendorSettlementperiod.equals("全部")
                &&vendorSettlementperiod.length()>0){
            query.lambda().like(Vendor::getVendorSettlementperiod,vendorSettlementperiod);
        }
        if(vendorHeadofpurchasing!=null&&vendorHeadofpurchasing.length()>0){
            query.lambda().like(Vendor::getVendorHeadofpurchasing,vendorHeadofpurchasing);
        }
        if(vendorContactphone!=null&&vendorContactphone.length()>0){
            query.lambda().like(Vendor::getVendorContactphone,vendorContactphone);
        }
        query.lambda().orderBy(true,false,Vendor::getVendorId);
        return baseMapper.selectPage(page,query);
    }
}
